package rad.framework.mda.properties;


import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.SubActionBars;
import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;

/**
 * une implementation du PropertyView comme un nouveau tab Eclipse Tabbed Properties View
 * 
 * @author boudyacho
 *
 */
public class AdvancedPropertySection extends org.eclipse.ui.views.properties.tabbed.AdvancedPropertySection {
	
	private SubActionBars subActionBars;

	private TabbedPropertySheetPage propertySheetPage;

	/* (non-Javadoc)
	 * @see org.eclipse.ui.views.properties.tabbed.AdvancedPropertySection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
	 */
	public void createControls(Composite parent,TabbedPropertySheetPage tabbedPropertySheetPage) {
		
		super.createControls(parent, tabbedPropertySheetPage);
		
		propertySheetPage = tabbedPropertySheetPage;
		page.setPropertySourceProvider(new TabbedPropertiesContentProvider(Activator.getDefault().getItemProvidersAdapterFactory()));

		subActionBars = new SubActionBars(tabbedPropertySheetPage.getSite().getActionBars());

		setActionBars(subActionBars);
	}

	/**
	 * Definir et preparer le actionBars pour cette section
	 * 
	 * @param actionBars le action bars pour cette page
	 */
	protected void setActionBars(IActionBars actionBars) {
		page.makeContributions(actionBars.getMenuManager(), actionBars.getToolBarManager(), actionBars.getStatusLineManager());
	}

	/* (non-Javadoc)
	 * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#aboutToBeHidden()
	 */
	public void aboutToBeHidden() {
		super.aboutToBeHidden();
		subActionBars.deactivate();
		subActionBars.updateActionBars();
	}


	/* (non-Javadoc)
	 * @see org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#aboutToBeShown()
	 */
	public void aboutToBeShown() {
		super.aboutToBeShown();
		subActionBars.activate();
		subActionBars.updateActionBars();
	}

	/**
	 * Retourne le propertySheetPage
	 * 
	 * @return le PropertySheetPage
	 */
	public TabbedPropertySheetPage getPropertySheetPage() {
		return propertySheetPage;
	}
}
